<div id="imgUpload" class="modal fade bs-modal-sm" tabindex="-2" role="dialog" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title">上传图片(<%=w%>*<%=h%>)</h4>
      </div>
      <div class="modal-body">
        <div class="row">
          <div class="form-group">
            <label for="picurl" class="col-sm-2 control-label"></label>
            <div class="col-sm-8">
              <div id="imgUploadQueue"></div>
              <div class="input-group">
                <input id="imgUpload_file_upload" name="imgUpload_file_upload" type="file" multiple="false">
                  <span class="input-group-btn">
                  <button class="btn btn-color current-time" type="button"
                          onclick="$('#imgUpload_file_upload').uploadifive('upload')">上传<i class="ti-upload ml5"></i></button>
                  </span>
              </div>
              <div id="imgUploadImage" style="padding: 5px;">
              </div>
              <input type="hidden" id="imgUploadPicurl" name="imgUploadPicurl" value="" >
            </div>
          </div>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取 消</button>
        <button id="imgUploadOK" type="button" class="btn btn-primary" data-loading-text="正在删除...">确 定</button>
      </div>
    </div>
  </div>
</div>
<script language="JavaScript">
  function imgUploadClearFile() {
    $("#imgUploadImage").html("");
    $("#imgUploadPicurl").val("");
  }
  $('#imgUpload_file_upload').uploadifive({
    'auto': false,
    'multi': false,
    'width': '100%',
    'height': '35',
    'buttonText': '请选择图片',
    'fileType': 'image/*',
    'fileSizeLimit': 1024,
    'queueSizeLimit': 1,
    'formData': {},
    'queueID': 'imgUploadQueue',
    'uploadScript': '/open/fileupload/<%if(type=='db'){%>dbimage<%}else if(type=='shop'){%>shopimage<%}else{%>image<%}%>',
    'onUploadComplete': function (file, data) {
      data = JSON.parse(data);
      if (data.code == 0) {
        Toast.success(data.msg);
        $("#imgUploadImage").html("<img src='" + data.path + "' style='width:<%=w%>px;height:<%=h%>px;'>");
        $("#imgUploadPicurl").val(data.path);
      } else {
        imgUploadClearFile();
        Toast.error(data.msg);
      }
    },
    'onDrop': function (file, fileDropCount) {
      imgUploadClearFile();
    },
    'onClearQueue': function (queue) {
      imgUploadClearFile();
    },
    'onCancel': function () {
      imgUploadClearFile();
    }
  });
</script>
